<?php

/**
 * This is the model class for table "participant".
 *
 * The followings are the available columns in table 'participant':
 * @property integer $P_id
 * @property integer $P_uid
 * @property integer $P_eid
 * @property string $P_fname
 * @property string $P_lname
 * @property string $P_minitial
 * @property string $P_address
 * @property string $P_city
 * @property string $P_state
 * @property integer $P_zip
 * @property integer $P_age
 * @property integer $P_current_grade
 * @property string $P_school_district
 */
class Participant extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Participant the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'participant';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('P_uid, P_eid,P_fname, P_lname, P_minitial, P_address, P_city, P_state, P_zip, P_age, P_current_grade, P_school_district', 'required'),
			array('P_id, P_uid, P_eid, P_zip, P_age, P_current_grade', 'numerical', 'integerOnly'=>true),
			array('P_fname, P_lname', 'length', 'max'=>30),
			array('P_minitial', 'length', 'max'=>1),
			array('P_state', 'length', 'max'=>2),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('P_id, P_uid, P_eid, P_fname, P_lname, P_minitial, P_address, P_city, P_state, P_zip, P_age, P_current_grade, P_school_district', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'P_id' => 'Participant Id',
			'P_uid' => 'User Id',
			'P_eid' => 'Event Id ',
			'P_fname' => 'First Name',
			'P_lname' => 'Last Name',
			'P_minitial' => 'Middle Initial',
			'P_address' => 'Address',
			'P_city' => 'City',
			'P_state' => 'State',
			'P_zip' => 'Zip',
			'P_age' => 'Age',
			'P_current_grade' => 'Current Grade',
			'P_school_district' => 'School District',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('P_id',$this->P_id);
		$criteria->compare('P_uid',$this->P_uid);
		$criteria->compare('P_eid',$this->P_eid);
		$criteria->compare('P_fname',$this->P_fname,true);
		$criteria->compare('P_lname',$this->P_lname,true);
		$criteria->compare('P_minitial',$this->P_minitial,true);
		$criteria->compare('P_address',$this->P_address,true);
		$criteria->compare('P_city',$this->P_city,true);
		$criteria->compare('P_state',$this->P_state,true);
		$criteria->compare('P_zip',$this->P_zip);
		$criteria->compare('P_age',$this->P_age);
		$criteria->compare('P_current_grade',$this->P_current_grade);
		$criteria->compare('P_school_district',$this->P_school_district,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}